<template>
  <div class="warp">
    <div class="title">视频监控 {{this.seletedCamera}}</div>
    <div class="main">
      <div class="video">
        <img src="../../assets/images/village-video.png" />
        <img src="../../assets/images/village-video.png" />
        <img src="../../assets/images/village-video.png" />
        <img src="../../assets/images/village-video.png" />
      </div>
      <!-- <div class="tab">
        <ul>
          <el-radio-group v-model="seletedCamera" size="small">
            <el-radio v-for="item in monitorArr" :key="item.id" :label="item.camaraName" border>{{item.camaraName}}</el-radio>
          </el-radio-group>
        </ul>
      </div>
      <div class="tab-button">
        <ul>
          <a href="javascript:void(0);" v-for="(item,index) in this.cameraPageTabs" :key="item.id">
            <li :class="{active:item.isActive}" @click="handleTabClick(index)"></li>
          </a>
        </ul>
      </div> -->
    </div>
  </div>
</template>
<script>
export default {
  name: 'villageMonitor',
  props: ['cameraList'],
  data () {
    return {
      seletedCamera: null,
      cameraPageCount: 0,
      cameraPageTabs: [],
      monitorArr: []
    }
  },
  watch: {
    cameraList (val) {
      this.initPage(val)
    }
  },
  computed: {},
  mounted: function () {
    this.initPage(this.cameraList)
  },
  methods: {
    initPage: function (val) {
      if (!val || !val.length || val.length === 0) {
        return
      }

      this.cameraPageCount = parseInt(val.length / 8)
      if (val.length % 8 > 0) {
        this.cameraPageCount++
      }

      this.cameraPageTabs = new Array(this.cameraPageCount)
      for (let i = 0; i < this.cameraPageCount; i++) {
        let arrTmp = val.slice(0)
        this.cameraPageTabs[i] = {
          isActive: false,
          monitor: arrTmp.slice(i * 8, i * 8 + 8)
        }
      }

      if (this.cameraPageCount > 0) {
        this.cameraPageTabs[0].isActive = true
        this.monitorArr = this.cameraPageTabs[0].monitor
        this.seletedCamera = this.monitorArr[0].camaraName
      } else {
        this.seletedCamera = ''
      }
    },
    // tab切换控制按钮
    handleTabClick: function (index) {
      this.cameraPageTabs.forEach((item, k, arr) => {
        console.log(item.id)
        arr[k].isActive = false
      })

      this.cameraPageTabs[index].isActive = true
      this.monitorArr = this.cameraPageTabs[index].monitor
      this.seletedCamera = this.monitorArr[0].camaraName
    }
  }
}
</script>
<style lang="less" scoped>
@light-green: #50e3c2;
.skin-white {
  .warp {
    color: #4c6072 !important;
  }
  .tab {
    li {
      color: #ffffff;
      background: @light-green;
    }
    a li {
      // color: rgb(51,51,51)!important;
      border: 1px solid rgb(57, 209, 176) !important;
    }
    a li:hover {
      background: rgb(57, 209, 176) !important;
      color: rgb(31, 31, 31) !important;
      border: 1px solid @light-green;
    }
  }
}

.warp {
  background: rgba(43, 54, 72, 0.7);
  border-radius: 4px;
  padding: 20px;
  box-sizing: border-box;
  color: #fff;
  margin-bottom: 10px;
  margin-left: 10px;
  width: 410px;
}

.title {
  font-size: 14px;
}

.main {
  .video {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    img {
      width: 180px;
      height: 100px;
      margin-top: 10px;
    }
  }
}
.el-radio.is-bordered {
  color: #fff !important;
  border: 1px solid #557345;
}
.el-radio--small.is-bordered {
  margin-left: 10px !important;
  margin-top: 5px !important;
}
.tab {
  margin-top: 25px;
  ul {
    list-style: none;
    display: inline-block;
    li {
      float: left;
      margin: 0 10px 8px 0;
      width: 118px;
      height: 28px;
      line-height: 28px;
      background: rgba(5, 5, 5, 0.2);
      text-align: center;
    }
    a li {
      color: #9facc3;
      text-decoration: none;
      border: 1px solid rgba(80, 227, 194, 0.5);
    }
    a li:hover {
      color: #fff;
      border: 1px solid @light-green;
    }
  }
}

.tab-button {
  margin: 8px 20px 0 0;
  text-align: center;
  ul {
    list-style: none;
    display: inline-block;
    li {
      float: left;
      margin: 3px;
      width: 10px;
      height: 10px;
      border-radius: 5px;
    }
    a li {
      background-color: #616c7c;
      color: transparent;
    }
    a li:hover {
      background-color: #50e3c2;
      color: transparent;
    }
  }
  .active {
    background-color: #50e3c2 !important;
  }
}

.hidden {
  display: none !important;
}
</style>
